package com.siki.vo;

import com.siki.pojo.model.DepartmentInformation;
import io.swagger.annotations.ApiModelProperty;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import io.swagger.annotations.ApiModel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@ApiModel("注册人员部门信息返回VO")
@Getter
@Setter
@NoArgsConstructor
public class SignUpIntentionVO {
    @ApiModelProperty("id")
    Long id;

    @ApiModelProperty("次序")
    Integer no;

    @ApiModelProperty("意愿部门名称")
    String departmentInfo;

    @ApiModelProperty("意愿部门名称")
    String post;

    @ApiModelProperty("部门审核状态")
    String resultType;


    public SignUpIntentionVO(DepartmentInformation departmentInformation) {
        Optional.ofNullable(departmentInformation).ifPresent(departmentInformations -> {
            this.id = departmentInformations.getId();
            this.no = departmentInformations.getNo();
            this.departmentInfo = departmentInformations.getDepartmentInfo();
            this.post = departmentInformations.getPost();
            this.resultType = departmentInformations.getResultType().toString();
        });
    }

    public static List<SignUpIntentionVO> getList(List<DepartmentInformation> departmentInformations) {
        List<SignUpIntentionVO> signUpIntentionVOS = new ArrayList<>();
        for (DepartmentInformation di :
                departmentInformations) {
            signUpIntentionVOS.add(new SignUpIntentionVO(di));
        }
        return signUpIntentionVOS;
    }
}
